package org.example.vaildation;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.example.anno.State;

public class StateValidation implements ConstraintValidator<State,String> {
    /**
     * @param value object to validate
     * @param context context in which the constraint is evaluated
     *
     * @return 返回false 不通过， true生效
     */
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if (value==null){
            return false;
        }
        if (value.equals("已发布")||value.equals("草稿")){
            return true;
        }
        return false;
    }
}
